package com.mlethe.android.demo.clearedit;

import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.mlethe.android.demo.R;
import com.mlethe.library.utils.app.KeyboardTool;
import com.mlethe.library.widget.clearedit.ClearEditText;

public class MainClearEditActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_clear_edit_main);
        ClearEditText commentEt = findViewById(R.id.commentEt);
        commentEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                Log.e("TAG", "beforeTextChanged: "+ s);
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Log.e("TAG", "onTextChanged: "+ s);
            }

            @Override
            public void afterTextChanged(Editable s) {
                Log.e("TAG", "afterTextChanged: "+ s);
            }
        });
        commentEt.setOnDeleteClickListener(new ClearEditText.OnDeleteClickListener() {
            @Override
            public void onClick() {
                Log.e("TAG", "onClick: ");
            }
        });

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                KeyboardTool.hideSoftInput(MainClearEditActivity.this, commentEt);
            }
        }, 3000);
    }
}
